use super::models:: { User, NewUser };
use super::schema::users::dsl::*;
use diesel::prelude::*;
use diesel::result::Error;


// HACK:
pub fn create_user(conn: &PgConnection, new_user: NewUser) -> Result<User, Error> {
    diesel::insert_into(users)
        .value(&new_user)
        .get_value(conn)
}

pub fn find_user_by_username(conn: &PgConnection, username_param:: &str) -> Result<User, Error> {
    users.filter(username.eq(username_param)).first(conn)
}
